package com.woniu.inlet.web;

import com.woniu.outlet.po.*;
import com.woniu.service.ICompanyBusinessService;
import com.woniu.util.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//主要处理对公客户的业务问题，比如存款业务的查询，贷款业务，银行卡业务！！
@RestController
@RequestMapping("/cli")
@Api(tags = "对公客户的业务操作")
public class CompanyBusinessController {

    @Autowired
    private ICompanyBusinessService companyBusinessService;

    //查看企业的活期账户信息，可以多条件查询(查询的都是本客户经理下面的客户信息)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "客户经理id",name = "wokerid",required = true,paramType = "query",dataType = "Integer"),
            @ApiImplicitParam(value = "对公客户id",name = "companyid",required = false,paramType = "query",dataType = "Integer")
    })
    @ApiOperation(value = "findCompanyCurrentAccount",notes = "查看企业的活期账户信息")
    @GetMapping("/findCompanyCurrentAccount")
    @PreAuthorize("hasRole('client')")
    public ResponseResult<List<CompanyCurrentAccount>> findCompanyCurrentAccount(Integer wokerid,Integer companyid){
        List<CompanyCurrentAccount> companyCurrentAccountlist = companyBusinessService.findCompanyCurrentAccount(wokerid, companyid);
        System.out.println(companyCurrentAccountlist);
        return new ResponseResult<>(companyCurrentAccountlist,200);
    }

    //可以根据客户的信息（比如客户的账户号）来查询客户的活期存款的记录
    @ApiImplicitParams({
            @ApiImplicitParam(value = "对公客户的银行账户", name = "companycurrentAccount", required = true,paramType = "query",dataType = "String")
    })
    @ApiOperation(value = "findCompanyCurrentTransfer",notes = "查询客户的活期存款的记录")
    @GetMapping("/findCompanyCurrentTransfer")
    @PreAuthorize("hasRole('client')")
    public ResponseResult<List<CompanyCurrentTransfer>> findCompanyCurrentTransfer(String companycurrentAccount){
        List<CompanyCurrentTransfer> companyCurrentTransferlist = companyBusinessService.findCompanyCurrentTransfer(companycurrentAccount);
        return new ResponseResult<>(companyCurrentTransferlist,200);
    }

    //查看企业的定期账户信息，可以多条件查询(查询的都是本客户经理下面的客户信息)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "客户经理id",name = "wokerid",required = true,paramType = "query",dataType = "Integer"),
            @ApiImplicitParam(value = "对公客户id",name = "companyid",required = false,paramType = "query",dataType = "Integer")
    })
    @ApiOperation(value = "findCompanyRegularAccount",notes = "查看企业的定期账户信息")
    @GetMapping("/findCompanyRegularAccount")
    @PreAuthorize("hasRole('client')")
    public ResponseResult<List<CompanyRegularAccount>> findCompanyRegularAccount(Integer wokerid,Integer companyid){
        List<CompanyRegularAccount> companyRegularAccount = companyBusinessService.findCompanyRegularAccount(wokerid, companyid);
        return new ResponseResult<>(companyRegularAccount,200);
    }

    //可以根据客户的信息（比如客户的账户号）来查询客户的定期存款的记录
    @ApiImplicitParams({
            @ApiImplicitParam(value = "对公客户的银行账户", name = "companyregularAccount", required = true,paramType = "query",dataType = "String")
    })
    @ApiOperation(value = "findCompanyRegularTransfer",notes = "查询客户的定期存款的记录")
    @GetMapping("/findCompanyRegularTransfer")
    @PreAuthorize("hasRole('client')")
    public ResponseResult<List<CompanyRegularTransfer>> findCompanyRegularTransfer(String companyregularAccount){
        List<CompanyRegularTransfer> companyRegularTransfer = companyBusinessService.findCompanyRegularTransfer(companyregularAccount);
        return new ResponseResult<>(companyRegularTransfer,200);
    }


    //查看企业的银行卡信息，可以多条件查询(查询的都是本客户经理下面的客户信息)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "客户经理id",name = "wokerid",required = true,paramType = "query",dataType = "Integer"),
            @ApiImplicitParam(value = "对公客户id",name = "companyid",required = false,paramType = "query",dataType = "Integer")
    })
    @ApiOperation(value = "findCompanyCard",notes = "查看企业的银行卡信息")
    @GetMapping("/findCompanyCard")
    @PreAuthorize("hasRole('client')")
    public ResponseResult<List<CompanyCard>> findCompanyCard(Integer wokerid,Integer companyid){
        List<CompanyCard> companyCard = companyBusinessService.findCompanyCard(wokerid, companyid);
        return new ResponseResult<>(companyCard,200);
    }

    //可以根据客户的信息（比如客户的账户号）来查询客户的银行卡存款的记录
    @ApiImplicitParams({
            @ApiImplicitParam(value = "对公客户的银行卡账户", name = "companycardNum", required = true,paramType = "query",dataType = "String")
    })
    @ApiOperation(value = "findCompanyCartTransfer",notes = "查询客户的银行卡存款的记录")
    @GetMapping("/findCompanyCartTransfer")
    @PreAuthorize("hasRole('client')")
    public ResponseResult<List<CompanyCartTransfer>> findCompanyCartTransfer(String companycardNum){
        List<CompanyCartTransfer> companyCartTransfer = companyBusinessService.findCompanyCartTransfer(companycardNum);
        return new ResponseResult<>(companyCartTransfer,200);
    }

    //查看企业的贷款信息，可以多条件查询(查询的都是本客户经理下面的客户信息)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "客户经理id",name = "wokerid",required = true),
            @ApiImplicitParam(value = "对公客户id",name = "companyid",required = false,paramType = "query",dataType = "Integer")
    })
    @ApiOperation(value = "findCompanyLoan",notes = "查看企业的贷款信息")
    @GetMapping("/findCompanyLoan")
    @PreAuthorize("hasRole('client')")
    public ResponseResult<List<CompanyLoan>> findCompanyLoan(Integer wokerid,Integer companyid){
        List<CompanyLoan> companyLoan = companyBusinessService.findCompanyLoan(wokerid, companyid);
        return new ResponseResult<>(companyLoan,200);
    }

    //可以根据客户的信息（比如客户的账户号）来查询客户的贷款的记录
    @ApiImplicitParams({
            @ApiImplicitParam(value = "对公客户贷款账户", name = "companyloanAccount", required = true,paramType = "query",dataType = "String")
    })
    @ApiOperation(value = "findCompanyLoanTransfer",notes = "查询客户的贷款的记录")
    @GetMapping("/findCompanyLoanTransfer")
    @PreAuthorize("hasRole('client')")
    public ResponseResult<List<CompanyLoanTransfer>> findCompanyLoanTransfer(String companyloanAccount){
        List<CompanyLoanTransfer> companyLoanTransfer = companyBusinessService.findCompanyLoanTransfer(companyloanAccount);
        return new ResponseResult<>(companyLoanTransfer,200);
    }



}
